var ipt = document.querySelectorAll('input');
var ttt1 = document.querySelectorAll('.ttt1');
var timg = document.querySelectorAll('img');
// var email = $('.email0[value$=".com"]');
var button = document.querySelector('#button');
// var tt1 = document.querySelectorAll('tt1');


ipt[0].onblur = function() {
    if (this.value.length < 2 || this.value.length > 8) {
        ttt1[0].innerHTML = '<img src="images/cha.png" alt="" class="timg" id="iuser">请输入2~8位用户名';
        ttt1[0].className = 'ttt1 wrong';
    } else {
        ttt1[0].innerHTML = '<img src="images/dui.png" alt="" class="timg" id="iuser">格式正确';
        ttt1[0].className = 'ttt1 right';
    }
}
ipt[1].onblur = function() {
    if (this.value.length < 6 || this.value.length > 16) {
        ttt1[1].innerHTML = '<img src="images/cha.png" alt="" class="timg" id="iuser">请输入6~16位密码';
        ttt1[1].className = 'ttt1 wrong';
    } else {
        ttt1[1].innerHTML = '<img src="images/dui.png" alt="" class="timg" id="iuser">格式正确';
        ttt1[1].className = 'ttt1 right';
    }
}
if (ipt.length < 3) {
    button.onclick = function() {
        if ((ttt1[0].className == ttt1[1].className) && ttt1[0].className == 'ttt1 right') {
            button.href = 'index.html';
        }
    }
}

if (ipt.length > 2) {
    ipt[2].onblur = function() {
        if (this.value != ipt[1].value || this.value.length < 6 || this.value.length > 16) {
            ttt1[2].innerHTML = '<img src="images/cha.png" alt="" class="timg" id="iuser">密码格式不正确';
            ttt1[2].className = 'ttt1 wrong';
        } else {
            ttt1[2].innerHTML = '<img src="images/dui.png" alt="" class="timg" id="iuser">格式正确';
            ttt1[2].className = 'ttt1 right';
        }

    }
    ipt[4].onblur = function() {
            if (this.value.length != 11) {
                ttt1[4].innerHTML = '<img src="images/cha.png" alt="" class="timg" id="iuser">手机号码格式不正确';
                ttt1[4].className = 'ttt1 wrong';
            } else {
                ttt1[4].innerHTML = '<img src="images/dui.png" alt="" class="timg" id="iuser">格式正确';
                ttt1[4].className = 'ttt1 right';
            }
        }
        // ipt[3].onblur = function() {
        //     if (email != null) {
        //         console.log('asdfasf');
        //     }
        // for (var i = 0; i < 4; i++) {
        //     ttt1['i' + 1] ==
        // }
    button.onclick = function() {
        if ((ttt1[0].className == ttt1[1].className) && (ttt1[1].className == ttt1[2].className) && (ttt1[2].className == ttt1[4].className) && ttt1[0].className == 'ttt1 right') {
            button.href = 'login.html';
        }
    }

}